import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/home/index.vue'
import Footer from '../components/Footer.vue'

const routes = [
  // 路由的重定向
  { path: '/', redirect: '/home' },
  {
    path: '/home',
    name: 'home',
    // component: Home
    components: {
      default: Home,
      footer: Footer
      // footer: () => import('../components/Footer.vue')
    },
  },
  {
    path: '/kind',
    name: 'kind',
    components: {
      default: () => import('../views/kind/index.vue'),
      footer: Footer
    },
  },
  {
    path: '/cart',
    name: 'cart',
    components: {
      default: () => import('@/views/cart/index.vue'),
      // footer: Footer
    }
  },
  {
    path: '/user',
    name: 'user',
    components: {
      default: () => import('@/views/user/index.vue'),
      footer: Footer
    }
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/register/index')
  },
  {
    path: '/detail/:id', // 传参
    name: 'detail',
    component: () => import('@/views/detail/index')
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/search/index')
  },
  {
    path: '/order',
    name: 'order',
    component: () => import('@/views/order/index.vue')
  },
  {
    path: '/order/list',
    name: 'orderList',
    component: () => import('@/views/order/list.vue')
  },
  {
    path: '/order/add',
    name: 'orderAdd',
    component: () => import('@/views/order/add.vue')
  },
  {
    path: '/order/edit/:id',
    name: 'orderEdit',
    component: () => import('@/views/order/edit.vue')
  },

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
})

export default router
